using System;
using System.Collections.Generic;
using EventBroker.Module;
using Mbs;
using Mbs.Windows;

namespace EventBroker.Views
{
    public partial class GlobalCustomerView : UserControlView,IGlobalCustomerView
    {
        public GlobalCustomerView()
        {
            InitializeComponent();
        }

        public override IEnumerator<IDisposable> Attach()
        {
            yield return CommandNames.AddCustomer.Attach(btnNewCustomer, Constance.Events.Control.Click);
            yield return CommandNames.NewCustomerList.Attach(btnNewCustomerList, Constance.Events.Control.Click);
        }

        public override IEnumerator<IDisposable> Subscribe()
        {
            yield return CommandNames.GlobalCustomerAdded.Subscribe<List<string>>((s, e) =>
                {
                    lstGlobalCustomers.DataSource = null;
                    lstGlobalCustomers.DataSource = e.Message;
                });
        }


        public string CustomerId
        {
            get { return txtCustomerId.Text; }
            set { txtCustomerId.Text = value; }
        }

        public void CustomerIdFocus()
        {
            txtCustomerId.Focus();
        }
    }
}